/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_set_player_message.cpp

	$Header: /heroes4/script_set_player_message.cpp $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "script_set_player_message.h"

#include "adventure_map.h"
#include "player.h"
#include "streambuf_operators.h"

// --------------------------------------------------------------------------
// t_script_set_player_message members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
bool t_script_set_player_message::read_from_map(
	std::streambuf &	stream,
	int					format_version )
{
	return		t_script_player_action::read_from_map( stream, format_version )
			&&	read_string16( stream, m_text );
}

bool t_script_set_player_message::read( std::streambuf& stream, int version )
{
	if (!t_script_player_action::read( stream, version ))
		return false;
	if (version >= 6)
		if (!read_string16( stream, m_text ))
			return false;
	return true;
}

bool t_script_set_player_message::write( std::streambuf& stream ) const
{
	if (!t_script_player_action::write( stream ))
		return false;
	write_string16( stream, m_text );
	return true;
}

void t_script_set_loss_condition_text::do_action( t_adventure_map* map, t_player* player ) const
{
	if (player == NULL)
		return;
	map->set_loss_condition_string( player->get_color(), get_text() );
}

void t_script_set_win_condition_text::do_action( t_adventure_map* map, t_player* player ) const
{
	if (player == NULL)
		return;
	map->set_victory_condition_string( player->get_color(), get_text() );
}

